<?php
/**
 * Created by PhpStorm.
 * User: sunzexin
 * Date: 2018/2/11
 * Time: 21:54
 */

namespace App\Http\Controllers\MiniProgram;


use App\Http\Logics\MiniProgram\FeedbackLogic;
use App\Http\Traits\FeedbackTrait;
use App\Http\Controllers\BaseController;
class FeedbackController extends BaseController
{
    use FeedbackTrait;

    /**
     * @SWG\Post(
     *     path="/feedback/create",
     *     tags={"Feedback"},
     *     description="createFeedback",
     *     operationId="创建反馈",
     *     produces={"application/json", "application/xml", "text/xml", "text/html"},
     *     @SWG\Parameter(
     *         name="loginSession",
     *         in="query",
     *         description="验证秘钥",
     *         required=false,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="content",
     *         in="query",
     *         description="反馈内容",
     *         required=false,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="parent_id",
     *         in="query",
     *         description="父ID",
     *         required=true,
     *         type="integer",
     *         format="int32"
     *     ),
     *     @SWG\Response(
     *         response=200,
     *         description="pet response"
     *     )
     * )
     */
    public function createFeedback()
    {
        $loginSession = $this->loginSession;
        $parent_id = $this->parent_id;
        $content = $this->content;
        $data = [
            'loginSession' => $loginSession,
            'parent_id' => $parent_id,
            'content' => $content
        ];
        $response = FeedbackLogic::createFeedback($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }

    /**
     * @SWG\Get(
     *     path="/feedback/list",
     *     tags={"Feedback"},
     *     description="getFeedbackList",
     *     operationId="获取反馈列表",
     *     produces={"application/json", "application/xml", "text/xml", "text/html"},
     *     @SWG\Parameter(
     *         name="loginSession",
     *         in="query",
     *         description="验证秘钥",
     *         required=false,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="limit",
     *         in="query",
     *         description="分页大小",
     *         required=false,
     *         type="integer",
     *         format="int32"
     *     ),
     *     @SWG\Parameter(
     *         name="parent_id",
     *         in="query",
     *         description="父ID",
     *         required=true,
     *         type="integer",
     *         format="int32"
     *     ),
     *     @SWG\Response(
     *         response=200,
     *         description="pet response"
     *     )
     * )
     */
    public function getFeedbackList()
    {
        $loginSession = $this->loginSession;
        $limit = $this->limit;
        $parent_id = $this->parent_id;
        $data = [
            'loginSession' => $loginSession,
            'limit' => $limit,
            'parent_id' => $parent_id
        ];
        $response = FeedbackLogic::getFeedbackList($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }
}